package com.xxxxx.Servlet;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/*
 * 请求转发跳转
 * 		request.getRequestDispatcher(url).forward(request,response);
 * 		可以让请求从服务端跳转到客户端(或跳转到指定的Servlet)
 * 	特点:
 * 		1. 服务器行为
 * 		2. 地址栏不发生改变
 * 		3. 从始至终只有1个请求
 * 		4. request数据可以共享
 */

@WebServlet("/S6")
public class TestServlet06 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			//获取uname
			String uname = request.getParameter("uname");
			//获取upwd
			String upwd = request.getParameter("upwd");
			
			System.out.println("姓名: "+ uname);
			System.out.println("密码: "+ upwd);
			
			//请求跳转到Servlet07
			//request.getRequestDispatcher("S7").forward(request, response);
			//请求跳转到jsp页面
			//request.getRequestDispatcher("login.jsp").forward(request, response);
			//请求跳转到html页面
			request.getRequestDispatcher("login.html").forward(request, response);
	}
		
}
